package com.test.deencredit.bean_deencredit.userinfo_deencredit;

import com.google.gson.Gson;

import org.json.JSONArray;
import org.json.JSONException;

import java.util.ArrayList;


public class AccountList_Fr_deencredit {

    private static class Inner {
        private static final AccountList_Fr_deencredit instance_deencredit = new AccountList_Fr_deencredit();
    }

    private AccountList_Fr_deencredit() {}

    public static AccountList_Fr_deencredit getInstance_deencredit() {
        return Inner.instance_deencredit;
    }

    private final ArrayList<BankAccount_Fr_deencredit> bankAccountList = new ArrayList<>();

    private Runnable parseRunnable;

    public static void parse_deencredit(JSONArray jsonArray) {

        Gson gson = new Gson();
        Inner.instance_deencredit.bankAccountList.clear();
        for (int i=0;i<jsonArray.length();i++){
            try {
                BankAccount_Fr_deencredit bankAccount = gson.fromJson(jsonArray.get(i).toString(), BankAccount_Fr_deencredit.class );
                Inner.instance_deencredit.bankAccountList.add(bankAccount);
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }

        if (Inner.instance_deencredit.parseRunnable!=null) Inner.instance_deencredit.parseRunnable.run();

    }

    public ArrayList<BankAccount_Fr_deencredit> getBankAccountList_deencredit() {
        return bankAccountList;
    }

    public void setParseRunnable_deencredit(Runnable parseRunnable) {
        this.parseRunnable = parseRunnable;
    }
}
